package com.naizhuai.Model.db.ainote;

import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.Query;
import android.arch.persistence.room.Update;

import com.naizhuai.Model.db.Tables;

import java.util.List;

/**
 * @author：lichenxi
 * @date 2018/2/22 11
 * email：525603977@qq.com
 * Fighting
 */
@Dao
public interface NoteDao {
    /**
     * Select all tasks from the tasks table.
     *
     * @return all tasks.
     */
    @Query("SELECT * FROM "+ Tables.NOTE_TABLE+" order by last_update desc" )
    List<Note> getNotes();

    @Query("SELECT * FROM "+ Tables.NOTE_TABLE+" order by title desc" )
    List<Note> getTitleNotes();

    @Query("SELECT * FROM "+ Tables.NOTE_TABLE+" order by creation desc" )
    List<Note> getCreationNotes();

    @Query("SELECT * FROM "+Tables.NOTE_TABLE+" WHERE noteid = :noteid")
    Note getNoteById(int noteid);


    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertTask(Note note);


    @Update
    int updateNote(Note note);

    @Delete
    void deleteNotes(List<Note> notes);



}
